package org.birrap.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;


@Entity
@Table(name = "TAPAS_CERVEZA_T")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "TapasCervezaT.findAll", query = "SELECT t FROM TapasCervezaT t"),
    @NamedQuery(name = "TapasCervezaT.findByIdTapa", query = "SELECT t FROM TapasCervezaT t WHERE t.idTapa = :idTapa"),
    @NamedQuery(name = "TapasCervezaT.findByNombre", query = "SELECT t FROM TapasCervezaT t WHERE t.nombre = :nombre"),
    @NamedQuery(name = "TapasCervezaT.findByDescripcion", query = "SELECT t FROM TapasCervezaT t WHERE t.descripcion = :descripcion"),
    @NamedQuery(name = "TapasCervezaT.removeById",query = "DELETE FROM TapasCervezaT t WHERE t.idTapa = :idTapa"),
})
@SequenceGenerator (name="SEQ_TAPAS_T" , sequenceName ="SEQ_TAPAS_T" , allocationSize = 1)

public class TapasCervezaT implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "ID_TAPA")
    @GeneratedValue (strategy = GenerationType.SEQUENCE, generator = "SEQ_TAPAS_T")
    private Integer idTapa;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "NOMBRE")
    private String nombre;
    @Size(max = 150)
    @Column(name = "DESCRIPCION")
    private String descripcion;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "tapasCervezaT")
    private Collection<BaresCervezasTapasVasosT> baresCervezasTapasVasosTCollection;

    public TapasCervezaT() {
    }

    public TapasCervezaT(Integer idTapa) {
        this.idTapa = idTapa;
    }

    public TapasCervezaT(Integer idTapa, String nombre) {
        this.idTapa = idTapa;
        this.nombre = nombre;
    }

    public Integer getIdTapa() {
        return idTapa;
    }

    public void setIdTapa(Integer idTapa) {
        this.idTapa = idTapa;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    @XmlTransient
    public Collection<BaresCervezasTapasVasosT> getBaresCervezasTapasVasosTCollection() {
        return baresCervezasTapasVasosTCollection;
    }

    public void setBaresCervezasTapasVasosTCollection(Collection<BaresCervezasTapasVasosT> baresCervezasTapasVasosTCollection) {
        this.baresCervezasTapasVasosTCollection = baresCervezasTapasVasosTCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idTapa != null ? idTapa.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TapasCervezaT)) {
            return false;
        }
        TapasCervezaT other = (TapasCervezaT) object;
        if ((this.idTapa == null && other.idTapa != null) || (this.idTapa != null && !this.idTapa.equals(other.idTapa))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.birrap.ejb.TapasCervezaT[ idTapa=" + idTapa + " ]";
    }
    
}
